<?php
    include($_SERVER['DOCUMENT_ROOT']."/ObstacleWebApp/view/headeradmin.php");
?>

<section>
<hgroup>
<h1>Kamers</h1>
</hgroup>

    Klik <a href="kamertoevoegen.php">hier</a> om een nieuwe kamer toe te voegen.
    
<?php
$page_name="kamers.php";
if (isset($_GET['start']))
{
    $start=$_GET['start'];
}
else
{
    $start=0;
}

if(strlen($start) > 0 and !is_numeric($start)){
	exit;
}
$eu = ($start - 0);
$limit = 20; // No of records to be shown per page.
$thi = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
$query2="SELECT * from roomtype";
$result2=mysql_query($query2);
$nume=mysql_num_rows($result2);
?>

<table id="rounded-corner">
    <thead>
    	<tr>
        	<th scope="col" class="rounded-company">Kamer-ID</th>
            <th scope="col" class="rounded-q1">Naam</th>
            <th scope="col" class="rounded-q2">Status</th>
            <th scope="col" class="rounded-q3">Onderdelen</th>
            <th scope="col" class="rounded-q4">Bewerken</th>
        </tr>
    </thead>
        <tfoot>
    	<tr>
        	<td colspan="4" class="rounded-foot-left">
        	<?php
	        	if ( $limit < $nume) {
	        		if($back >=0) {
						echo "<a href='$page_name?start=$back'>Vorige</a>";
					}
	        		$i=0;
					$l=1;
					for($i=0;$i < $nume;$i=$i+$limit){
						if($i <> $eu)
						{
							echo " <a href='$page_name?start=$i'>$l</a> ";
						}
						else 
						{ 
							echo "<span style=\"font-weight:bold;\">$l</span>";
						}
						$l=$l+1;
					}
	        		if($thi < $nume) 
	        		{
						echo "<a href='$page_name?start=$next'>Volgende</a>";
					}
				}
        	?>
        	</td>
        	<td class="rounded-foot-right">&nbsp;</td>
        </tr>
    </tfoot>
    <tbody>
<?php

$sql1 = "SELECT * from roomtype limit $eu, $limit";
$result1 = mysql_query($sql1) or die (mysql_error());
while($row = mysql_fetch_array($result1))
{

echo "<tr><td>".$row['Id']."</td>";
echo "<td>" . $row['Name']."</td>";
if ($row['Activated'] == "T")
{
    $activated = "Geactiveerd";
}
else
{
    $activated = "Gedeactiveerd";
}
echo "<td>" . $activated."</td>";
echo "<td><a href=\"kameronderdelen.php?kamer=".$row['Id']."\" >Bekijk onderdelen</a></td>";
echo "<td><a href=\"kameraanpassen.php?id=".$row['Id']."\" >Bewerken</a></td>";



}

?>
</tbody>
</table>


</section>
<?php
    include($_SERVER['DOCUMENT_ROOT']."/ObstacleWebApp/view/footer.php");
?>
